package com.realife.eson.common.exception;


import com.realife.eson.common.enums.ResponseEnum;
import lombok.Getter;
import org.joda.time.DateTime;

@Getter
public class ExceptionResult {

    private int statusCode; //状态码
    private String message; //消息内容
    private String timestamp; //时间

    public ExceptionResult(BusinessException e) {
        this.statusCode = e.getStatusCode();
        this.message = e.getMessage();
        this.timestamp = DateTime.now().toString("yyyy-MM-dd HH:mm:ss");
    }


    public ExceptionResult(Exception t) {
        this.statusCode = ResponseEnum.EXCEPTION_EXC.getStatusCode();
        this.message = t.getMessage();
        this.timestamp = DateTime.now().toString("yyyy-MM-dd HH:mm:ss");
    }


    public ExceptionResult(Throwable t) {
        this.statusCode = ResponseEnum.THROWABLE_ERR.getStatusCode();
        this.message = t.getMessage();
        this.timestamp = DateTime.now().toString("yyyy-MM-dd HH:mm:ss");
    }
}
